home *** CD-ROM | disk | FTP | other *** search
/ Carousel Volume 2 #1 / carousel.iso / mactosh / john / hc_quick.hqx / Quick Compacter™ 1.0.2 / stack.txt < prev   
Encoding:
Text File  |  1989-11-15  |  8.7 KB  |  283 lines

  1. -- stack: in.2
  2. -- format: 8 (HyperCard 1)
  3. -- flags: 0x1000 (none)
  4. -- protect password hash: 0
  5. -- maximum user level: 5 (scripting)
  6. -- window: Rect(x1=0, y1=0, x2=0, y2=0)
  7. -- screen: Rect(x1=0, y1=0, x2=0, y2=0)
  8. -- card dimensions: w=0 h=0
  9. -- scroll: x=0 y=0
  10. -- background count: 1
  11. -- first background id: 2588
  12. -- card count: 1
  13. -- first card id: 2975
  14. -- list block id: 2058
  15. -- print block id: 0
  16. -- font table block id: 0
  17. -- style table block id: 0
  18. -- free block count: 0
  19. -- free size: 0 bytes
  20. -- total size: 39616 bytes
  21. -- stack block size: 9216 bytes
  22. -- created by hypercard version: 0x01228000
  23. -- compacted by hypercard version: 0x01228000
  24. -- modified by hypercard version: 0x01228000
  25. -- opened by hypercard version: 0x01228000
  26. -- patterns[0]: 0x0000000000000000
  27. -- patterns[1]: 0x8000000008000000
  28. -- patterns[2]: 0x8800220088002200
  29. -- patterns[3]: 0x8888222288882222
  30. -- patterns[4]: 0x88AA22AA88AA22AA
  31. -- patterns[5]: 0xCCAA33AACCAA33AA
  32. -- patterns[6]: 0xEEAABBAAEEAABBAA
  33. -- patterns[7]: 0xEEBBBBEEEEBBBBEE
  34. -- patterns[8]: 0xFFBBFFEEFFBBFFEE
  35. -- patterns[9]: 0xFFBBFFFFFFBBFFFF
  36. -- patterns[10]: 0x8010022001084004
  37. -- patterns[11]: 0xFFFFFFFFFFFFFFFF
  38. -- patterns[12]: 0x8822882288228822
  39. -- patterns[13]: 0x1122448811224488
  40. -- patterns[14]: 0xC4800C6843023026
  41. -- patterns[15]: 0xB130031BD8C00C8D
  42. -- patterns[16]: 0xAA00AA00AA00AA00
  43. -- patterns[17]: 0x8822552288225522
  44. -- patterns[18]: 0x8855225588552255
  45. -- patterns[19]: 0x77DD77DD77DD77DD
  46. -- patterns[20]: 0x8000000000000000
  47. -- patterns[21]: 0xAA55AA55AA55AA55
  48. -- patterns[22]: 0x038448300C020101
  49. -- patterns[23]: 0x8244394482010101
  50. -- patterns[24]: 0x8814224188412214
  51. -- patterns[25]: 0x8080413E080814E3
  52. -- patterns[26]: 0x22048C7422179810
  53. -- patterns[27]: 0xBE808808EB088880
  54. -- patterns[28]: 0x25C8328964244C92
  55. -- patterns[29]: 0xA29C41BE2AC914EB
  56. -- patterns[30]: 0x40A00000040A0000
  57. -- patterns[31]: 0x8040200002040800
  58. -- patterns[32]: 0xAA00800088008000
  59. -- patterns[33]: 0xFF80808080808080
  60. -- patterns[34]: 0x081C22C180010204
  61. -- patterns[35]: 0xFF808080FF080808
  62. -- patterns[36]: 0xF87422478F172271
  63. -- patterns[37]: 0xBF00BFBFB0B0B0B0
  64. -- patterns[38]: 0xFF7FBE5DA2418000
  65. -- patterns[39]: 0xFAF5FAF5A050A050
  66. -- checksum: 0x0
  67. ----- HyperTalk script -----
  68. ---------------------open stack,checks to clear report flds-------------
  69. on OpenStack
  70.   global totsav,nmQC,cur,f1,tst,QLvar
  71.   put empty into QLvar
  72.   put CleanUp into temp
  73.   if cd fld MultCheckΓëá1 then
  74.     if cd fld "Title" is not empty and cd fld "Totsavings" is not empty then
  75.       answer "Some information was left in the Report field" with "Clear It" or "Leave It"
  76.       if it= "Clear It" then
  77.         put empty into cd fld "Title"
  78.         put empty into cd fld "BSaved"
  79.         put empty into cd fld "PerSaved"
  80.         put 0 into cd fld "Totsavings"
  81.         put 0 into totsav
  82.       end if
  83.       if it = "Leave It" then
  84.         put cd fld "Totsavings" into totsav
  85.       end if
  86.     end if
  87.   end if
  88.   put 0 into cur
  89.   set the scroll of cd fld id 4 to cur
  90.   set the scroll of cd fld id 25 to cur
  91.   set the scroll of cd fld id 53 to cur
  92.   put long name of this stack into nmQC
  93. end OpenStack
  94. -----------------Cleans up stack before quiting-------------------------
  95. on CloseStack
  96.   global cur
  97.   put CleanUp into temp
  98.   put 0 into cur
  99.   set the scroll of cd fld id 4 to cur
  100.   set the scroll of cd fld id 25 to cur
  101.   set the scroll of cd fld id 53 to cur
  102.   set locktext of cd fld "Totsavings" to true
  103.   set locktext of cd fld "Title" to true
  104.   set locktext of cd fld "BSaved" to true
  105.   put the freesize of this stack into fsQC
  106.   if fsQC>0 then domenu "Compact Stack"
  107. end CloseStack
  108. -----------------------------------------------------------------------
  109. ----- This is the 'Guts' of the program...this does all the compaction
  110. -----------------------------------------------------------------------
  111. on DoIt
  112.   global tst,totsav,nmQC,Numb,TotNumb,StackPath,Multcnt,ComStatus, Etst,QLtst,QLSTKName
  113.   put empty into d
  114.   put empty into u
  115.   put empty into chr
  116.   put empty into TargSTK
  117.   ---only on Single or MultCom
  118.   if ComStatus="S" or ComStatus="Mult"
  119.   then
  120.   put "Number"&&Numb&&"of"&&TotNumb into temp
  121.   put "Attempt to compact which stack?"&&temp
  122.   put empty into temp
  123.   Put FileName("STAK") into TargSTK
  124.   set cursor to watch
  125.   if TargSTK is empty
  126.   then
  127.   put 1 into tst
  128.   exit DoIt
  129. end if
  130. set lockscreen to true   -----these two lines will reset the screen
  131. set lockscreen to false  -----so that the outline disappears
  132. put short name of TargSTK into d
  133. put "Checking stack:"&&d
  134. put Che(TargSTK,ComStatus) into chr
  135. if chr="S,Y" then exit Doit
  136. if chr="M,Y,D"
  137. then
  138. put 1 into tst
  139. exit Doit
  140. end if
  141. if chr="M,Y,C" then exit Doit
  142. end if
  143. if ComStatus="ENTFLDR" then  ------------only for Entire FLDR com
  144.   put the short name of StackPath into StackName
  145.   put "Checking stack:"&&StackName
  146.   put Che(StackPath,ComStatus) into chr
  147.   if chr="E,Y,C" then exit Doit ---continue with loop
  148.   if chr="E,Y,D" then ----exit Entire Folder compact loop
  149.     put 1 into Etst
  150.     exit Doit
  151.   end if
  152.   put StackPath into TargSTK
  153. end if
  154. if ComStatus="Q1" then ----------------only for single QL compact
  155.   put "Checking stack:"&&QLSTKName
  156.   put Che(StackPath,ComStatus) into chr
  157.   if chr="Q1,Y" then exit Doit
  158.   put StackPath into TargSTK
  159. end if
  160. if ComStatus="Q2" then --------------only for entire QL compact
  161.   put "Checking stack:"&&QLSTKName
  162.   put Che(StackPath,ComStatus) into chr
  163.   if chr="Q2,Y,C" then exit Doit
  164.   if chr="Q2,Y,D" then
  165.     put 1 into QLtst
  166.     exit Doit
  167.   end if
  168.   put StackPath into TargSTK
  169. end if
  170. ----End of Error Checking...all stacks should be compactable--------
  171. put the size of stack TargSTK into STS
  172. put freeSize of stack TargSTK into FTS
  173. if FTS=0 then
  174.   if ComStatus="Mult" then
  175.     answer "That stack does not need to be compacted." with "Cancel Run" or "Continue Run"
  176.     if it="Cancel Run" then
  177.       put 1 into tst
  178.     end if
  179.   else
  180.     put the short name of TargSTK into temp
  181.     put temp&&"does not need to be compacted."
  182.   end if
  183.   exit Doit
  184. end if
  185. put the number of chars of FTS into c
  186. put FTS into Cb
  187. if c>3 then
  188.   put char c-3 of Cb into temp
  189.   put temp&"," into char c-3 of Cb
  190. end if
  191. set lockscreen to true
  192. set lockmessages to true
  193. put short name of TargSTK into d
  194. go to TargSTK
  195. put Userlevel into u
  196. if u<5 then set Userlevel to 5
  197. set cantModify of stack TargSTK to false
  198. put "Attempting to Compact"&&Cb&&"bytes in"&&d
  199. if StackPath is not empty then add 1 to Multcnt
  200. domenu compact stack         ----This compacts the stack (duh!)
  201. set lockMessages to false
  202. show msg
  203. go to nmQC
  204. put "Finished compacting:"&&d
  205. set lockscreen to false
  206. put the number of lines in cd fld "Title" into LnsRep
  207. add 1 to LnsRep
  208. put Round(FTS/STS*100) into Prs
  209. put d into line(LnsRep) of cd fld "Title"
  210. put Cb into line(LnsRep) of cd fld "BSaved"
  211. put Prs&&"%" into line(LnsRep) of cd fld "PerSaved"
  212. add FTS to totsav
  213. put totsav into cd fld "Totsavings"
  214. end Doit
  215. -------------------------Check the write permission--------------------
  216. function Che TargSTK, ComStatus
  217. global QLSTKName
  218. put WritePermission(TargSTK,false) into WriteResult
  219. -------Single Compaction Check---------------
  220. if ComStatus="S" then
  221.   if WriteResult=false then
  222.     put the short name of TargSTK into temp
  223.     put temp&&"can not be opened to compact."
  224.     answer "That stack is locked or in use." with "OK"
  225.     return "S,Y"
  226.   else
  227.     return "S,N"
  228.   end if
  229. end if
  230. -----Multiple Compaction Check-------------
  231. if ComStatus="Mult" then
  232.   if WriteResult=false then
  233.     put the short name of TargSTK into temp
  234.     put temp&&"is locked or in use. Can not be opened to compact."
  235.     answer "That stack is locked or in use." with "Cancel Run" or "Continue Run"
  236.     if it="Continue Run" then return "M,Y,C"
  237.     if it="Cancel Run" then
  238.       return "M,Y,D"
  239.     end if
  240.   else
  241.     return "M,N"
  242.   end if
  243. end if
  244. -----Entire Folder Compaction Check------------------------
  245. if ComStatus="ENTFLDR" then
  246.   if WriteResult=false then
  247.     put the short name of TargSTK into temp
  248.     put temp&&"is locked. Can not be opened to compact."
  249.     answer "That stack is locked or in use." with "Cancel Run" or "Continue Run"
  250.     if it="Continue Run" then return "E,Y,C"
  251.     if it="Cancel Run" then
  252.       return "E,Y,D"
  253.     end if
  254.   else
  255.     return "E,N"
  256.   end if
  257. end if
  258. -----------Quick List Compaction Check (one file only)---------------
  259. if ComStatus="Q1" then
  260.   if WriteResult=false then
  261.     put QLSTKName&&"can not be opened to compact."
  262.     answer "That stack is locked or in use." with "OK"
  263.     return "Q1,Y"
  264.   else
  265.     return "Q1,N"
  266.   end if
  267. end if
  268. -----------Quick List Compact Entire List-------------------------
  269. if ComStatus="Q2" then
  270.   if WriteResult=false then
  271.     put QLSTKName&&"could be locked or not in expected location."
  272.     answer "That stack is locked or in use." with "Cancel Run" or "Continue Run"
  273.     if it="Continue Run" then return "Q2,Y,C"
  274.     if it="Cancel Run" then
  275.       return "Q2,Y,D"
  276.     end if
  277.   else
  278.     return "Q2,N"
  279.   end if
  280. end if
  281. end Che
  282.  
  283.